package com.jihox.abookpro.fragment;

import android.app.Fragment;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.jihox.abookpro.GuideActivity;
import com.jihox.abookpro.MyApplication;
import com.jihox.abookpro.R;

public class MessageFragment extends Fragment{

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View view=inflater.inflate(R.layout.activity_message, container, false);
		TextView versionText = (TextView)view.findViewById(R.id.text_version);
		versionText.setText(getVersion());
//		LinearLayout helpLayout = (LinearLayout)view.findViewById(R.id.layout_help_preview);
//		helpLayout.setOnClickListener(new OnClickListener(){
//
//			@Override
//			public void onClick(View arg0) {
//				Intent intent = new Intent(MyApplication.getInstance(), GuideActivity.class);
//				intent.putExtra("fromHelp", true);
//				startActivity(intent);
//			}});
		return view;
	}
	
	/**
	 * 获取版本号
	 * @return 当前应用的版本号
	 */
	public String getVersion() {
	    try {
	    	MyApplication application = MyApplication.getInstance();
	        PackageManager manager = application.getPackageManager();
	        PackageInfo info = manager.getPackageInfo(application.getPackageName(), 0);
	        String version = info.versionName;
	        return version;
	    } catch (Exception e) {
	        e.printStackTrace();
	        return "";
	    }
	}
}
